package com.lcj.ai.model;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;

@Data
@Schema(description = "统一结果实体")
public class ResultDTO<T> implements Serializable {
    @Schema(description = "是否成功")
    private boolean success;
    @Schema(description = "状态码")
    private Integer code;
    @Schema(description = "返回消息")
    private String message;
    @Schema(description = "返回数据")
    private T data;

    public ResultDTO() {
    }

    public ResultDTO(boolean success, Integer code, String message, T data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> ResultDTO<T> success() {
        return new ResultDTO<>(true, 200, "success", null);
    }

    public static <T> ResultDTO<T> success(T data) {
        return new ResultDTO<>(true, 200, "success", data);
    }

    public static <T> ResultDTO<T> fail(Integer code, String message) {
        return new ResultDTO<>(false, code, message, null);
    }

    public static <T> ResultDTO<T> fail(String message) {
        return new ResultDTO<>(false, 500, message, null);
    }
}
